package com.romotc.qqrobot.webqq.qqInterfaceCatching;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;

import org.json.JSONException;

import com.romotc.json.tools.Jackson;
import com.romotc.qqrobot.bean.QQInfoFromQQLogedin;
import com.romotc.qqrobot.bean.QQInfoFromQQLogedinService;
import com.romotc.qqrobot.bean.QQLogedin;
import com.romotc.qqrobot.webqq.WebQQConstant;
import com.romotc.scache.RequestSpy;
import com.romotc.scache.WebConnection;
/**
 * 虚拟Qq获取好友信息拦截器
 * @author Administrator
 * 请求信息：Get http://s.web2.qq.com/api/get_friend_info2
 * 		?tuin=1&verifysession=&code=
 * 		&vfwebqq=af3q86nKcb14Mqd65mPxvAoAA5r06A1NzQT0Vr9oMD1pRa5wHWch9l0qFAJNLUOtaw306Y6BcAa3qmOQ
 * 		&t=1328063534675
 * 
 * 返回信息:QQInfoFromQQLogedin
 * {"retcode":0,"result":{"face":540,"birthday":{"month":3,"year":2011,"day":17},"occupation":"","phone":"","allow":0,"college":"","reg_time":0,"uin":1586030808,"constel":2,"blood":0,"homepage":"","stat":20,"vip_info":0,"country":"中国","city":"济南","personal":"","nick":"opendev","shengxiao":4,"email":"","province":"山东","gender":"male","mobile":""}}
 */
public class Get_friend_info2_CustService_Catching extends CustService_QQUrlBodyCatching {

	@Override
	String getHackReqBodyStr(RequestSpy requestSpy, Map<String, Object> var) {
		
		QQLogedin curQq = getCurQqLogedIn(requestSpy);
		long tuin = requestSpy.getReqInfoJson().optLong(WebQQConstant.REQUEST_PARAMS_tuin,0);
			
		QQInfoFromQQLogedin qqInfo = null;
		if(tuin > 0) {//是查询获取虚拟QQ号码的信息
			//查询客服人员资料并组织成QQInfoFromQQlogedIn格式
			qqInfo = QQInfoFromQQLogedinService.qryQqMemCustInfo(tuin);
		}else if(tuin < 0){//是查询客户信息
			//查询客户信息 并组织成QQInfoFromQQlogedIn格式
			qqInfo = QQInfoFromQQLogedinService.qryCustQQInfo(-tuin);
		}
		
		if(qqInfo != null) {
			return qqInfo.getInfo();
		}
		
		return "{\"retcode\":0,\"result\":{\"face\":540,\"birthday\":{\"month\":3,\"year\":2011,\"day\":17},\"occupation\":\"\",\"phone\":\"\",\"allow\":0,\"college\":\"\",\"reg_time\":0,\"uin\":" +
				tuin + ",\"constel\":2,\"blood\":0,\"homepage\":\"\",\"stat\":20,\"vip_info\":0,\"country\":\"中国\",\"city\":\"\",\"personal\":\"\",\"nick\":\"opendev\",\"shengxiao\":4,\"email\":\"\",\"province\":\"\",\"gender\":\"male\",\"mobile\":\"\"}}";
	}

	@Override
	ArrayList<String> hackRequestHeader(RequestSpy requestSpy, int bodySize,
			Map<String, Object> var) {
		// TODO Auto-generated method stub
		return null;
	}


}
